Skip to content

Ship cross toolchains in each wheel - #8

Closed
dwoz wants to merge 1 commit into
mainfrom
add-cross-toolchains
Closed

dwoz wants to merge 1 commit into
mainfrom
add-cross-toolchains

Conversation

@dwoz

@dwoz dwoz commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Each wheel now carries every toolchain configured under src/ppbt/_config/<host>/ instead of just the host's native one. The x86_64 wheel ships both x86_64-linux-gnu.tar.xz and aarch64-linux-gnu.tar.xz; the aarch64 wheel ships both in reverse. Downstream consumers (relenv) can cross-compile the "other" Linux arch without building a crosstool-ng toolchain themselves (several-hour yak-shave previously).
  • New public helpers in ppbt.common (also re-exported from ppbt): archive_for(triplet), toolchain_for(triplet), available_triplets(). extract() and environ() grow a triplet= kwarg defaulting to the host, so pre-0.2.0 callers keep working unchanged.
  • build_ppbt refactored: _prepare_crosstool_ng + _prepare_patchelf run once per build; _build_one_toolchain runs once per <triplet>-ct-ng.config. Single-arch hosts (configs that only define the native triplet) get the original behaviour.

Why

relenv needs to cross-build onedirs for aarch64 from an x86_64 runner (and vice versa) to validate saltstack/relenv#37 (cross-build relenv relocate). Without a prebuilt cross toolchain shipped in ppbt, every cross build has to compile glibc from source — which is why nobody actually exercises the cross-build path today.

Test plan

  • pytest tests/ passes (new tests/test_common.py covers archive_for, toolchain_for, available_triplets, environ(triplet=...), and the re-exports).
  • pre-commit run clean on all touched files (black reformatted a few lines, flake8 clean).
  • CI wheel build produces one tarball per config and the resulting wheel contains both.
  • Downstream: patch relenv's get_toolchain() to call ppbt.archive_for(triplet) and cross-build an aarch64 onedir from an x86_64 host end-to-end.

Build every <triplet>-ct-ng.config under src/ppbt/_config/<host>/ into
its own tarball, so the x86_64 wheel carries both x86_64-linux-gnu and
aarch64-linux-gnu toolchains (and vice versa for the aarch64 wheel).
The native-only behaviour is preserved for hosts that have only a single
config.

Factor build_ppbt's per-toolchain work into _prepare_crosstool_ng,
_prepare_patchelf, and _build_one_toolchain so the crosstool-ng and
patchelf download/compile happens once per invocation rather than once
per target.

Expose archive_for(triplet), toolchain_for(triplet), and
available_triplets() in ppbt.common (re-exported from ppbt) so callers
like relenv can pick the matching tarball out of the wheel. extract()
and environ() grow a triplet= kwarg defaulting to the host for
backward compatibility.
@dwoz dwoz mentioned this pull request Nov 21, 2026
3 of 6 tasks
@dwoz

dwoz commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #9, which splits the cross toolchains into separate PyPI packages (ppbt-cross-aarch64-linux-gnu, ppbt-cross-x86_64-linux-gnu) installable via pip install ppbt[cross-aarch64-linux-gnu] extras. Keeps the base ppbt wheel at its current ~40 MiB rather than doubling it.

@dwoz dwoz closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant